x=eval(input())
y=(5*x+8)%26
print(y)
z=(21*(y-8))%26
print("x=",x)
print("z=",z)

i=eval(input())
n=eval(input())
q=eval(input())
if q==1:
    s=n
    print(s)
else:
    sum=i*((q**n)-1)/(q-1)
    print("sum=",sum)



